Skip to content

fix(workers): cap atlas-search and id-mail POST bodies (#11331) - #11435

Merged
dezren39 merged 1 commit into
mainfrom
fix/11331-search-mail-body-cap
Nov 17, 2026
Merged

dezren39 merged 1 commit into
mainfrom
fix/11331-search-mail-body-cap

Conversation

@dezren39

@dezren39 dezren39 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Closes #11331

Before: POST /v1/search on the atlas-search Worker and the id-mail Worker's POST handler read the body with a bare json() after auth. One oversized request cost the Worker full memory and parse time before any check.

After: both refuse a declared Content-Length over 64 KiB without reading, and read undeclared bodies through a capped reader that stops at the cap. atlas-search answers 413 {"error":{"code":"payload_too_large",...}}; id-mail answers 413 {"error":"body is too large"}. Normal bodies and the existing 400 envelopes for non-JSON and non-object bodies are unchanged. 64 KiB is far above what either route needs ({ query, k }; a mail request is capped at 10,000 text characters plus a subject and addresses).

How: pkgs/atlas-search/worker/src/body.ts (readTextUpTo) used by src/index.ts; the same reader inline in nixos/services/id-mail/worker/src/index.js.

Testing:

  • id-mail: three new tests in runtime.test.mjs (declared oversize never read, drip-fed oversize stops at the cap, 400 envelopes and a normal send still work). npm test: 20 pass; the two oversize tests fail without the change.
  • atlas-search: new test/body.test.ts and an end-to-end 413 case in test/worker.test.ts. This package's vitest pool can't install here (lockfile resolves through a registry the sandbox can't reach), so I ran body.test.ts under node with a small vitest shim: 5 pass. The vitest suite itself has not been run.

Generated by Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Both handlers read the request body with a bare json() after auth, so
one oversized request cost the Worker full memory and parse time. Each
now refuses a declared Content-Length over 64 KiB without reading, and
reads undeclared bodies through a capped reader that stops at the cap,
answering 413 in the route's own envelope. The existing 400 envelopes
for non-JSON and non-object bodies are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dezren39
dezren39 marked this pull request as ready for review November 17, 2026 22:39
@dezren39
dezren39 requested a review from a team as a code owner November 17, 2026 22:39
@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7b52e74c-2b1a-406d-9689-2b4e4140d9dc
Commits

Reviewing files that changed from the base of the PR and between c2f25e4 and 42c2ffa.

Files selected for processing: 6

  • nixos/services/id-mail/worker/runtime.test.mjs
  • nixos/services/id-mail/worker/src/index.js
  • pkgs/atlas-search/worker/src/body.ts
  • pkgs/atlas-search/worker/src/index.ts
  • pkgs/atlas-search/worker/test/body.test.ts
  • pkgs/atlas-search/worker/test/worker.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T22:40:56.951579Z 42c2ffa Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 merged commit ea6a5f3 into main Nov 17, 2026
1 check passed
@dezren39
dezren39 deleted the fix/11331-search-mail-body-cap branch November 17, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

atlas-search(worker) + id-mail(worker): POST handlers read request bodies with no size cap

2 participants